class Validate {
  //获取元素
  query(name) {
    return document.querySelector(name)
  }

  //键盘输入方式
  confirm_Password(password, confirmPassword, message, errorEl, eventType) {
    let elements = document.querySelectorAll(`[name='${password}'] , [name='${confirmPassword}']`)
    let This = this
    elements.forEach(function (elem) {
      elem.addEventListener(eventType, function () {
        const passwordValue = This.query(`[name='${password}']`).value
        const confirmPasswordValue = This.query(`[name='${confirmPassword}']`).value
        if (passwordValue != confirmPasswordValue) {
          This.query(errorEl).innerHTML = message
        } else {
          This.query(errorEl).innerHTML = ''
        }
      })
    })
  }
}
